// Created by WXX on 2021/10/22 16:21
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：4 ms, 在所有 C++ 提交中击败了71.94%的用户
 * 内存消耗：7.6 MB, 在所有 C++ 提交中击败了57.20%的用户
 */
class Solution {
public:

    vector<vector<int>> ans;
    vector<int> path;
    vector<bool> st;

    vector<vector<int>> permute(vector<int>& nums) {

        int n = nums.size();
        path.resize(n);
        st.resize(n);
        dfs(nums, 0);
        return ans;
    }

    void dfs(vector<int> &nums, int u) {

        if (u == nums.size()) {
            ans.push_back(path);
            return;
        }

        for (int i = 0; i < nums.size(); i++)
            if (!st[i]) {
                st[i] = true;
                path[u] = nums[i];
                dfs(nums, u + 1);
                st[i] = false;
            }
    }
};

int main() {


    return 0;
}
